<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            width: 100%;
            height: 2000px;
        }
        header{
            position: fixed;
            width: 100%;
            top: 0;
            left: 0;
        }
        input{
            display: block;
            width:100%;
            line-height: 30px;
            font-size: 12px;
            background: #ccc
        }
        footer{
            position: fixed;
            left: 0;
            bottom: 0;
            height: 20px;
            width: 100%;
            background: #666;
        }
    </style>
</head>
<body>
    <header>
        <input type="text" placeholder="测试">
    </header>       
    <footer>
        
    </footer>
    <script>
        
        var inp = document.querySelector('input');
        var foot = document.querySelector('footer')
        inp.addEventListener('focus',function () {
            foot.style.position = 'static'
        })
        inp.addEventListener('blur',function () {
            foot.style.position = 'fixed'
        })
    </script>
</body>
</html>